<?php
$imagenes_dir = 'http://meridianoraid.com/intranet/uploads/imagen';
$imagenes_dir = 'http://localhost/bimbacheraid/uploads/imagen';
$cultura = 'es';

// DATABASE VARIABLES
function db($variable) {
  $db = array();
  $db['dbhost'] = '127.0.0.1'; //MySQL Host
  $db['dbname'] = 'semoen'; //Database Name
  $db['dbuname'] = 'root'; //Database Username
  $db['dbpass'] = 'toor'; //Database password
  $db['prefix'] = ''; //Database prefix

  
  $db['dberror'] = '<strong>Hubo un error al conectar con la base de datos.</strong>.'; //Database error message
  return $db[$variable];
}

function countRows($tabla) {
	$query =  "SELECT count( id ) AS count FROM ".db('prefix').$tabla;
	$result = mysql_query($query);
	$result = mysql_fetch_array($result);
	$result = $result['count'];
	return $result;
}

function retrieveWithI18n($table, $field, $value, $culture, $order="") {
  $query = "SELECT * FROM ".db('prefix').$table.", ".$table."_i18n WHERE ".$table.".id = ".$table."_i18n.id AND culture='".$culture."' ";
  if ($field != "")  
    $query .= " AND ".$table.".".$field." = '".$value."' ";
  if ($order != "")
    $query .= " ORDER BY ".$order;
  $result = mysql_query($query);
  //$r = mysql_fetch_array($result);
  return $result;
}

function retrieve($table, $field, $value, $order="") {
  $query = "SELECT * FROM ".db('prefix').$table." ";
  if ($field != "")  
    $query .= " WHERE ".$table.".".$field." = '".$value."' ";
  if ($order != "")
    $query .= " ORDER BY ".$order;
  $result = mysql_query($query);
  //$r = mysql_fetch_array($result);
  return $result;
}

function connect_to_db() {
  $db = mysql_connect(db('dbhost'), db('dbuname'), db('dbpass'));
  mysql_select_db(db('dbname')) or die(db('dberror'));
/*   if (mysql_num_rows(mysql_query("SHOW TABLES LIKE '".db('prefix')."noticia'")) != 1) {
      die(db('db_tables_error'));
   }
   echo '<p>hola que pasa</p>';*/
}

function insert($table,$fields,$values) {
    $query = "INSERT INTO ".$table." ".$fields." values ".$values;
    $response = mysql_query($query);
    return $response;
}
//connect_to_db();
//insert("twitts", "", "(2,'otrakk','http://hola.com','tururu',0)")


/***********************************************************************/
/***********************************************************************/
/***********************************************************************/
/***********************************************************************/
/***********************************************************************/


?>